package homework2;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class Test02 {
    public static void main(String[] args) throws ParseException {
        System.out.println("请输入你的出生期-------格式为:yyyy-MM-dd");
        int count=0;
        boolean flag=true;
        while (flag){
            Scanner scanner = new Scanner(System.in);
            String str = scanner.next();
            //计算活了多少天
            calculate(str);
            count++;
            if(count==3){
                flag=false;
            }
        }
    }
    public static void calculate(String str) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = simpleDateFormat.parse(str);//将定义的出生日期转换为系统时间
        long boredTime = parse.getTime();//将出生时间换算成毫秒值
        Date date = new Date();
        long nowDate = date.getTime();//将当前系统时间换算成毫秒值
        int live = (int) huansuan(boredTime, nowDate);
        System.out.println("你已经来了这个世界"+live+"天");
    }
    public static long huansuan(long boredTime,long nowDate){
        long huo=nowDate-boredTime;
        int lived= (int) (huo/1000/60/60/24);
        return lived;
    }
}
